Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | import { NextResponse } from 'next/server' import { getRoomMembers } from '@/lib/arcade/room-membership' import { getRoomHistoricalMembersWithStatus } from '@/lib/arcade/room-member-history' import { withAuth } from '@/lib/auth/withAuth' import { getUserId } from '@/lib/viewer' /** * GET /api/arcade/rooms/:roomId/history * Get all historical members with their current status (host only) * Returns: array of historical members with status info */ export const GET = withAuth(async (_request, { params }) => { try { const { roomId } = (await params) as { roomId: string } const userId = await getUserId() // Check if user is the host const members = await getRoomMembers(roomId) const currentMember = members.find((m) => m.userId === userId) if (!currentMember) { return NextResponse.json({ error: 'You are not in this room' }, { status: 403 }) } if (!currentMember.isCreator) { return NextResponse.json({ error: 'Only the host can view room history' }, { status: 403 }) } // Get all historical members with status const historicalMembers = await getRoomHistoricalMembersWithStatus(roomId) return NextResponse.json({ historicalMembers }, { status: 200 }) } catch (error: any) { console.error('Failed to get room history:', error) return NextResponse.json({ error: 'Failed to get room history' }, { status: 500 }) } }) |